import { defineStore } from 'pinia';

export const useUserStore = defineStore('user', {
  state: () => ({
    token: '',
    userInfo: null,
    role: '',
  }),
  actions: {
    setUser(token, userInfo) {
      this.token = token;
      this.userInfo = userInfo;
      this.role = userInfo?.role || '';
    },
    logout() {
      this.token = '';
      this.userInfo = null;
      this.role = '';
    },
  },
}); 